package cn.chinaflame.pagodas.repository;

import cn.chinaflame.pagodas.entity.PaMember;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

public interface PaMemberRepository extends JpaRepository<PaMember, String>, JpaSpecificationExecutor<PaMember> {

    @Query("select c from PaMember c where c.mobile = ?1")
    public PaMember findByMobile(String mobile);

    @Query("select c from PaMember c where c.loginId = ?1")
    public PaMember findByLoginId(String loginId);

    @Query("select c from PaMember c where c.email = ?1")
    public PaMember findByEmail(String email);

    @Query("select c from PaMember c where c.idNo = ?1")
    public PaMember findByIdNo(String idNo);

    @Query("select c from PaMember c where c.mobile = ?1 and c.loginPwd = ?2 and c.registFlg = ?3")
    public PaMember findByMobileAndPwd(String mobile, String loginPwd, String registFlg);

    @Query("select c from PaMember c where c.loginId = ?1 and c.loginPwd = ?2 and c.registFlg = ?3")
    public PaMember findByLoginIdAndPwd(String loginId, String loginPwd, String registFlg);

    @Query("select c from PaMember c where c.email = ?1 and c.loginPwd = ?2 and c.registFlg = ?3")
    public PaMember findByEmailAndPwd(String email, String loginPwd, String registFlg);

    @Query("select c from PaMember c where c.openid = ?1")
    public PaMember findPaMemberByOpenid(String openid);
}
